//
//  YGExpertsMsgVIew.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/3/22.
//

#import "YGExpertsMsgVIew.h"



@interface YGExpertsMsgVIew ()

@property(nonatomic,strong)UIButton *expertsBtn;
@property (nonatomic, strong) UIImageView *bodyimage;
@property (nonatomic, strong) UILabel *expertsNameLable;
@property(nonatomic,strong) UILabel *professionLable;
@property (nonatomic, strong) UILabel *specialtyLable;






@end
@implementation YGExpertsMsgVIew

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initContraints];
    }
    return self;
}

- (void)initView{
    
    [self addSubview:self.expertsBtn];
    [self addSubview:self.bodyimage];
    [self addSubview:self.expertsNameLable];
    [self addSubview:self.professionLable];
    [self addSubview:self.specialtyLable]; 
    
}

//修改专家个人信息
-(void)fixexpertsMsgWith:(YGExpertsModel *)model{
    NSString *imageUrl =model.headimgUrl;
    NSURL *url =[NSURL URLWithString:imageUrl];
    [_bodyimage sd_setImageWithURL:url];
    
    NSString *name =model.memberName;
    _expertsNameLable.text=name;
    
    NSString *maintittle=model.mainTitle;
    _professionLable.text=maintittle;
    
    NSString *goodAt =model.beGoodAt;
    _specialtyLable.text=goodAt;
    
}


- (void)initContraints{
    
    [self.expertsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(1);
            make.left.mas_equalTo(self.mas_left).offset(1);
            make.right.mas_equalTo(self.mas_right).offset(-1);
            make.bottom.mas_equalTo(self.mas_bottom).offset(-1);
        
    }];
    
    [self.bodyimage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.expertsBtn.mas_centerY);
            make.left.mas_equalTo(self.expertsBtn.mas_left).offset(10);
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(70);
        
            
    }];
    
    [self.expertsNameLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.bodyimage.mas_right).offset(5);
            make.top.mas_equalTo(self.expertsBtn.mas_top).offset(10);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(12);
            
    }];
    
    [self.professionLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.bodyimage.mas_right).offset(5);
        make.top.mas_equalTo(self.expertsNameLable.mas_bottom).offset(15);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(12);
        
    }];
    
    [self.specialtyLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.bodyimage.mas_right).offset(5);
            make.top.mas_equalTo(self.professionLable.mas_bottom).offset(15);
            make.width.mas_equalTo(120);
            make.height.mas_equalTo(12);
        
        
            
    }];
    
    
}


#pragma setter
- (UIButton *)expertsBtn{
    if (!_expertsBtn) {
        _expertsBtn = [[UIButton alloc]init];
        _expertsBtn.backgroundColor=UIColorFromRGB(0xffffff);
//        [_expertsBtn.layer setMasksToBounds:YES];
//        [_expertsBtn.layer setCornerRadius:3.0];//设置矩圆角半径,数值越大圆弧越大，反之圆弧越小
//        [_expertsBtn.layer setBorderWidth:1.0];//边框宽度
//        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
//        CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 55, 200, 215, 1 });//R,G,B,alpha
//        [_expertsBtn.layer setBorderColor:colorref];//设置边框颜色
    }
    return _expertsBtn;
}

- (UIImageView *)bodyimage{
    if (!_bodyimage) {
        _bodyimage = [[UIImageView alloc]init];
        
    }
    return _bodyimage;
}

- (UILabel *)expertsNameLable{
    if (!_expertsNameLable) {
        _expertsNameLable =[[UILabel alloc]init];
        _expertsNameLable.font= [UIFont systemFontOfSize:14];
        _expertsNameLable.textColor=UIColorFromRGB(0x333333);
    }
    return _expertsNameLable;
}

- (UILabel *)professionLable{
    if (!_professionLable) {
        _professionLable =[[UILabel alloc]init];
        _professionLable.font= [UIFont systemFontOfSize:14];
        _professionLable.textColor=UIColorFromRGB(0x333333);
        
    }
    return _professionLable;
}

- (UILabel *)specialtyLable{
    if (!_specialtyLable) {
        _specialtyLable = [[UILabel alloc]init];
        _specialtyLable.font= [UIFont systemFontOfSize:14];
        _specialtyLable.textColor=UIColorFromRGB(0x333333);
        
    }
    return _specialtyLable;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
